/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package onlinestore.GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextField;
import onlinestore.Product;

/**
 *
 * @author Li
 */
public final class SearchFrame extends JFrame implements ActionListener{

    Product p = new Product();
    SORFile s = new SORFile();
    public SearchFrame()
    {
        System.out.println("Open the serach Page...");
        
        JPanel sInfoPanel = new JPanel();
        sInfoPanel.setBackground(Color.YELLOW);
        sInfoPanel.setBounds(20, 20, 740, 40);
        add(sInfoPanel);

        JLabel sInfo = new JLabel();
        sInfo.setBounds(20, 20, 300, 20);
        System.out.println(s.readFromFiile());
        sInfo.setFont(new Font("Courier New",Font.PLAIN,16));
        sInfo.setText("You search for ["+s.readFromFiile()+"]");
        sInfoPanel.add(sInfo);

        showProduct();

        Container contentPane = getContentPane();
        contentPane.setBackground(Color.BLACK);
        contentPane.setLayout(new BorderLayout());
        setBounds(0, 0, 800, 800);
        setLocationRelativeTo(null);
        setTitle("Could --- Search Page --- Online Store");
        setDefaultCloseOperation(HIDE_ON_CLOSE);
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
     public void showProduct()
    {

            //Product Panel
            JPanel pPanel = new JPanel();
            JLabel pName = new JLabel();
            JLabel pStock = new JLabel();
            JLabel pTags = new JLabel();
            JLabel pPrice = new JLabel();
            JLabel pBuy = new JLabel();
            JTextField pAmount = new JTextField();
            JButton pAddToCart = new JButton("Add to my cart");

            pName.setText("ProductName:");//+p.getName());
            pName.setBounds(190, 20, 150, 20);
            pPanel.add(pName);

            pPrice.setText("The Price: ");//+p.getPrice());
            pPrice.setBounds(190, 50, 80, 20);
            pPanel.add(pPrice);

//            pStock.setText("We have : "+stock);
//            pStock.setBounds(190, 80, 80, 20);
//            pPanel.add(pStock);

//            pTags.setText("Description: "+tags);
//            pTags.setBounds(190, 110, 80, 20);
//            pPanel.add(pTags);

            pBuy.setText("How much you want: ");
            pBuy.setBounds(190, 140, 150, 20);
            pPanel.add(pBuy);

            pAmount.setBounds(320, 140, 50, 20);
            pPanel.add(pAmount);

            pAddToCart.setBounds(190, 170, 160, 28);
            pPanel.add(pAddToCart);

            pPanel.setBackground(Color.WHITE);
            pPanel.setBounds(20, 90, 740, 240);
            pPanel.setLayout(null);
            add(pPanel);

            ImageIcon PIC = new ImageIcon();//p.getPic());
            JLabel pPic = new JLabel(PIC);
            pPic.setBounds(20, 20, 150, 200);
            Component add = pPanel.add(pPic);

    }
    public void noProduct(String product)
    {
        //Product Panel
        JPanel pPanel = new JPanel();
        pPanel.setBackground(Color.RED);
        pPanel.setBounds(20, 20, 740, 240);
        pPanel.setLayout(null);
        add(pPanel);

        //NO Product info Label
        JLabel noProduct = new JLabel();
        noProduct.setText("Sorry, You seacrh "+product+" did not match any products.");
    }
}
